package cn.example.viewpager;

import android.graphics.Color;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.PagerTabStrip;
import android.support.v4.view.PagerTitleStrip;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends FragmentActivity {

    private List<View> viewList = new ArrayList<>();
    private List<String> strList = new ArrayList<>();
    private ViewPager viewPager;
    private PagerTabStrip pagerTabStrip;
    private PagerTitleStrip pagerTitleStrip;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //activity中转为view 1 2 3组件
        View view1 = View.inflate(this, R.layout.view1, null);
        View view2 = View.inflate(this, R.layout.view1, null);
        View view3 = View.inflate(this, R.layout.view1, null);
        //组件
        viewList.add(view1);
        viewList.add(view2);
        viewList.add(view3);
        //选项卡
        strList.add("第一页");
        strList.add("第二页");
        strList.add("第三页");
        viewPager = findViewById(R.id.myview_pager);
        //pagerTabStrip = findViewById(R.id.myview_TabStrip);
        pagerTitleStrip= findViewById(R.id.myview_title);
        // 不带标题
        //myViewAdpter adpter = new myViewAdpter(viewList);
        // 带标题适配器
        myViewAdpter adpter = new myViewAdpter(viewList, strList);
        viewPager.setAdapter(adpter);
       // pagerTabStrip.setBackgroundColor(Color.YELLOW);
       // pagerTabStrip.setTextColor(Color.BLACK);

    }
}
